<%@ page import="java.util.jar.Attributes.Name"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="support.*,java.util.*" %>
    
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>More degree</title>
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
	Applicant a = (Applicant) session.getAttribute("applicant");
	LinkedList<Degree> degrees = a.getDegrees();
	Degree degree = null;
	Major major = null;
	if(degrees == null)
	{
		degrees = new LinkedList<Degree>();
		a.setDegrees(degrees);
		degree = new Degree();
		degrees.add(degree);
	}
	degree = degrees.getLast();
	int discipline_id;
	String discipline = (String)request.getParameter("discipline");
	String discipline_name = (String)request.getParameter("discipline_name");
	String month = (String)request.getParameter("month");
	String year = (String)request.getParameter("year");
	String gpa = (String)request.getParameter("gpa");
	String title = (String)request.getParameter("title");
	DatabaseAccessObject dao = new DatabaseAccessObject();
	//if a discipline is chosen
	if(discipline.equals("")) {
		discipline_id = Integer.valueOf((String)request.getParameter("discipline_id"));
		if(discipline_id != -1)
		{
			discipline = dao.getMajorNameById(discipline_id);
			major = new Major(discipline_id,discipline);
		}
		//if the major is entered manually by this user for his/her previous degrees
		else
		{
			major = new Major(-1,discipline_name);
		}
	}
	//if the major is entered manually for current degree
	else
	{
		major = new Major(-1, discipline);
	}
	
	degree.setMajor(major);
	degree.setMonth(month.equals("") ? 0 : Integer.valueOf(month));
	degree.setYear(year.equals("") ? 0 : Integer.valueOf(year));
	degree.setGpa(gpa.equals("") ? 0 : Float.valueOf(gpa));
	degree.setTitle(title);
%>


<jsp:include page="degree_display.jsp"></jsp:include>
<br/>
<form name="form1" method="post">
	<input type="submit" value = "Submit Next Degree" onclick="document.forms['form1'].action = 'degree_location.jsp'">
	<input type="submit" value = "Done" onclick="document.forms['form1'].action = 'specialization.jsp'">
</form>	
</body>
</html>